On Contact Added Event
Fires when the SDK successfully adds a new contact to the user’s wallet.
-
Purpose: Notify your application that a new contact record is available. This is typically used to update contact lists, refresh UI, or trigger further provisioning workflows.
-
Functionality: Receives a
ContactModel
object. -
Usage:
- Persist the new contact in local storage or state management (Redux, Context API).
- Update any contact directories or UI components to include the new entry.
- Trigger follow-up actions (e.g. fetch available credentials from this issuer).
-
Example:
import { ContactModel } from '@one37id/mobile-js-sdk';
const handlers: EventHandlers = {
onContactAdded: async (model: ContactModel) => {
console.debug(
`Contact added event: ${JSON.stringify(model, null, 2)}`
);
// 1) Save to your DB or Redux
await contactService.addContact(model);
// 2) Refresh UI list
contactEventEmitter.emit('contactListUpdated');
},
};